<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>二维码生成器</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="./assets/qrcode.js"></script>
</head>
<body>
<div class="container">

	<div class="row">
		<h1 style="text-align: center;padding-bottom: 2rem;">二维码生成器</h1>
	</div>
	<div class="row" style="padding:2rem;">
		<div class="col-md-8 col-md-offset-2"><input type="text" class="form-control str" placeholder="请输入要生成二维码的内容" ></div>
		<div class="col-md-2"><button class="btn btn-info sub">确定</button></div>
	</div>
	<div class="row" style="text-align: center;">
		<div class="col-md-12 show"></div>
	</div>
</div>	
	
</body>
</html>

<script>

var q=$(".show").qrcode("请输入要生成二维码的内容");

$(".sub").click(setCode);
$(".str").on("keydown",function(e){
	if(e.keyCode==13){
		setCode();
	}
})	

function setCode(){
	var str=$(".str").val();
	$(".show").html("").qrcode(str);
}

</script>